<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Configuring Boost.Build</title>
<link rel="stylesheet" href="../boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../index.html" title="Boost.Python">
<link rel="up" href="../building.html" title="Chapter 2. Building and Testing">
<link rel="prev" href="installing_boost_python_on_your_.html" title="Installing Boost.Python on your System">
<link rel="next" href="choosing_a_boost_python_library_.html" title="Choosing a Boost.Python Library Binary">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/boost.png"></td></tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="installing_boost_python_on_your_.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../building.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="choosing_a_boost_python_library_.html"><img src="../images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="building.configuring_boost_build"></a><a class="link" href="configuring_boost_build.html" title="Configuring Boost.Build">Configuring Boost.Build</a>
</h3></div></div></div>
<div class="toc"><dl class="toc">
<dt><span class="section"><a href="configuring_boost_build.html#building.configuring_boost_build.python_configuration_parameters">Python
        Configuration Parameters</a></span></dt>
<dt><span class="section"><a href="configuring_boost_build.html#building.configuring_boost_build.examples">Examples</a></span></dt>
</dl></div>
<p>
        As described in the <a href="http://www.boost.org/build/doc/html/bbv2/overview/configuration.html" target="_top">Boost.Build
        Reference Manual</a>, a file called <code class="computeroutput"><span class="identifier">user</span><span class="special">-</span><span class="identifier">config</span><span class="special">.</span><span class="identifier">jam</span></code> in
        your home directory is used to specify the tools and libraries available
        to the build system. You may need to create or edit <code class="computeroutput"><span class="identifier">user</span><span class="special">-</span><span class="identifier">config</span><span class="special">.</span><span class="identifier">jam</span></code> to
        tell Boost.Build how to invoke Python, <code class="computeroutput"><span class="preprocessor">#include</span></code>
        its headers, and link with its libraries.
      </p>
<div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>
          If you are using a unix-variant OS and you ran Boost's <code class="computeroutput"><span class="identifier">configure</span></code>
          script, it may have generated a <code class="computeroutput"><span class="identifier">user</span><span class="special">-</span><span class="identifier">config</span><span class="special">.</span><span class="identifier">jam</span></code>
          for you. <a href="#ftn.building.configuring_boost_build.f0" class="footnote" name="building.configuring_boost_build.f0"><sup class="footnote">[2]</sup></a> If your <code class="computeroutput"><span class="identifier">configure</span></code>/<code class="computeroutput"><span class="identifier">make</span></code> sequence was successful and Boost.Python
          binaries were built, your <code class="computeroutput"><span class="identifier">user</span><span class="special">-</span><span class="identifier">config</span><span class="special">.</span><span class="identifier">jam</span></code>
          file is probably already correct.
        </p></td></tr>
</table></div>
<p>
        If you have one fairly “standard” python installation for your platform,
        you might not need to do anything special to describe it. If you haven't
        configured python in <code class="computeroutput"><span class="identifier">user</span><span class="special">-</span><span class="identifier">config</span><span class="special">.</span><span class="identifier">jam</span></code> (and
        you don't specify <code class="computeroutput"><span class="special">--</span><span class="identifier">without</span><span class="special">-</span><span class="identifier">python</span></code>
        on the Boost.Build command line), Boost.Build will automatically execute
        the equivalent of
      </p>
<pre class="programlisting"><span class="identifier">import</span> <span class="identifier">toolset</span> <span class="special">:</span> <span class="keyword">using</span> <span class="special">;</span>
<span class="keyword">using</span> <span class="identifier">python</span> <span class="special">;</span>
</pre>
<p>
        which automatically looks for Python in the most likely places. However,
        that only happens when using the Boost.Python project file (e.g. when referred
        to by another project as in the quickstart method). If instead you are linking
        against separately-compiled Boost.Python binaries, you should set up a <code class="computeroutput"><span class="identifier">user</span><span class="special">-</span><span class="identifier">config</span><span class="special">.</span><span class="identifier">jam</span></code> file
        with at least the minimal incantation above.
      </p>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="building.configuring_boost_build.python_configuration_parameters"></a><a class="link" href="configuring_boost_build.html#building.configuring_boost_build.python_configuration_parameters" title="Python Configuration Parameters">Python
        Configuration Parameters</a>
</h4></div></div></div>
<p>
          If you have several versions of Python installed, or Python is installed
          in an unusual way, you may want to supply any or all of the following optional
          parameters to <code class="computeroutput"><span class="keyword">using</span> <span class="identifier">python</span></code>.
        </p>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">version</span></dt>
<dd><p>
                the version of Python to use. Should be in Major.Minor format, for
                example, <code class="computeroutput"><span class="number">2.3</span></code>. Do not
                include the subminor version (i.e. <span class="bold"><strong>not</strong></span>
                <code class="computeroutput"><span class="number">2.5</span><span class="special">.</span><span class="number">1</span></code>). If you have multiple Python versions
                installed, the version will usually be the only configuration argument
                required.
              </p></dd>
<dt><span class="term">cmd-or-prefix</span></dt>
<dd><p>
                preferably, a command that invokes a Python interpreter. Alternatively,
                the installation prefix for Python libraries and header files. Only
                use the alternative formulation if there is no appropriate Python
                executable available.
              </p></dd>
<dt><span class="term"><span class="bold"><strong>includes</strong></span></span></dt>
<dd><p>
                the <code class="computeroutput"><span class="preprocessor">#include</span></code> paths
                for Python headers. Normally the correct path(s) will be automatically
                deduced from <code class="computeroutput"><span class="identifier">version</span></code>
                and/or <code class="computeroutput"><span class="identifier">cmd</span><span class="special">-</span><span class="keyword">or</span><span class="special">-</span><span class="identifier">prefix</span></code>.
              </p></dd>
<dt><span class="term"><span class="bold"><strong>libraries</strong></span></span></dt>
<dd><p>
                the path to Python library binaries. On MacOS/Darwin, you can also
                pass the path of the Python framework. Normally the correct path(s)
                will be automatically deduced from <code class="computeroutput"><span class="identifier">version</span></code>
                and/or <code class="computeroutput"><span class="identifier">cmd</span><span class="special">-</span><span class="keyword">or</span><span class="special">-</span><span class="identifier">prefix</span></code>.
              </p></dd>
<dt><span class="term"><span class="bold"><strong>condition</strong></span></span></dt>
<dd><p>
                if specified, should be a set of Boost.Build properties that are
                matched against the build configuration when Boost.Build selects
                a Python configuration to use. See examples below for details.
              </p></dd>
<dt><span class="term"><span class="bold"><strong>extension-suffix</strong></span></span></dt>
<dd><p>
                A string to append to the name of extension modules before the true
                filename extension. You almost certainly don't need to use this.
                Usually this suffix is only used when targeting a Windows debug build
                of Python, and will be set automatically for you based on the value
                of the <a class="link" href="python_debugging_builds.html" title="Python Debugging Builds">&lt;python-debugging&gt;</a>
                feature. However, at least one Linux distribution (Ubuntu Feisty
                Fawn) has a specially configured <a href="https://wiki.ubuntu.com/PyDbgBuilds" target="_top">&lt;python-dbg&gt;</a>
                package that claims to use such a suffix.
              </p></dd>
</dl>
</div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="building.configuring_boost_build.examples"></a><a class="link" href="configuring_boost_build.html#building.configuring_boost_build.examples" title="Examples">Examples</a>
</h4></div></div></div>
<p>
          Note that in the examples below, case and <span class="bold"><strong>especially
          whitespace</strong></span> are significant.
        </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p class="simpara">
              If you have both python 2.5 and python 2.4 installed, <code class="computeroutput"><span class="identifier">user</span><span class="special">-</span><span class="identifier">config</span><span class="special">.</span><span class="identifier">jam</span></code> might contain
            </p>
<pre class="programlisting"><span class="keyword">using</span> <span class="identifier">python</span> <span class="special">:</span> <span class="number">2.5</span> <span class="special">;</span>  <span class="special">#</span> <span class="identifier">Make</span> <span class="identifier">both</span> <span class="identifier">versions</span> <span class="identifier">of</span> <span class="identifier">Python</span> <span class="identifier">available</span>
<span class="keyword">using</span> <span class="identifier">python</span> <span class="special">:</span> <span class="number">2.4</span> <span class="special">;</span>  <span class="special">#</span> <span class="identifier">To</span> <span class="identifier">build</span> <span class="identifier">with</span> <span class="identifier">python</span> <span class="number">2.4</span><span class="special">,</span> <span class="identifier">add</span> <span class="identifier">python</span><span class="special">=</span><span class="number">2.4</span>
                      <span class="preprocessor"># to</span> <span class="identifier">your</span> <span class="identifier">command</span> <span class="identifier">line</span><span class="special">.</span>
</pre>
<p class="simpara">
              The first version configured (2.5) becomes the default. To build against
              python 2.4, add <code class="computeroutput"><span class="identifier">python</span><span class="special">=</span><span class="number">2.4</span></code>
              to the <code class="computeroutput"><span class="identifier">bjam</span></code> command
              line.
            </p>
</li>
<li class="listitem">
<p class="simpara">
              If you have python installed in an unusual location, you might supply
              the path to the interpreter in the <code class="computeroutput"><span class="identifier">cmd</span><span class="special">-</span><span class="keyword">or</span><span class="special">-</span><span class="identifier">prefix</span></code>
              parameter:
            </p>
<pre class="programlisting"><span class="keyword">using</span> <span class="identifier">python</span> <span class="special">:</span> <span class="special">:</span> <span class="special">/</span><span class="identifier">usr</span><span class="special">/</span><span class="identifier">local</span><span class="special">/</span><span class="identifier">python</span><span class="special">-</span><span class="number">2.6</span><span class="special">-</span><span class="identifier">beta</span><span class="special">/</span><span class="identifier">bin</span><span class="special">/</span><span class="identifier">python</span> <span class="special">;</span>
</pre>
</li>
<li class="listitem">
<p class="simpara">
              If you have a separate build of Python for use with a particular toolset,
              you might supply that toolset in the <code class="computeroutput"><span class="identifier">condition</span></code>
              parameter:
            </p>
<pre class="programlisting"><span class="keyword">using</span> <span class="identifier">python</span> <span class="special">;</span>  <span class="special">#</span> <span class="identifier">use</span> <span class="keyword">for</span> <span class="identifier">most</span> <span class="identifier">toolsets</span>

<span class="preprocessor"># Use</span> <span class="identifier">with</span> <span class="identifier">Intel</span> <span class="identifier">C</span><span class="special">++</span> <span class="identifier">toolset</span>
<span class="keyword">using</span> <span class="identifier">python</span>
     <span class="special">:</span> <span class="special">#</span> <span class="identifier">version</span>
     <span class="special">:</span> <span class="identifier">c</span><span class="special">:\\</span><span class="identifier">Devel</span><span class="special">\\</span><span class="identifier">Python</span><span class="special">-</span><span class="number">2.5</span><span class="special">-</span><span class="identifier">IntelBuild</span><span class="special">\\</span><span class="identifier">PCBuild</span><span class="special">\\</span><span class="identifier">python</span> <span class="special">#</span> <span class="identifier">cmd</span><span class="special">-</span><span class="keyword">or</span><span class="special">-</span><span class="identifier">prefix</span>
     <span class="special">:</span> <span class="special">#</span> <span class="identifier">includes</span>
     <span class="special">:</span> <span class="special">#</span> <span class="identifier">libraries</span>
     <span class="special">:</span> <span class="special">&lt;</span><span class="identifier">toolset</span><span class="special">&gt;</span><span class="identifier">intel</span> <span class="special">#</span> <span class="identifier">condition</span>
     <span class="special">;</span>
</pre>
</li>
<li class="listitem">
<p class="simpara">
              If you have downloaded the Python sources and built both the normal
              and the <a class="link" href="python_debugging_builds.html" title="Python Debugging Builds">"python
              debugging"</a> builds from source on Windows, you might see:
            </p>
<pre class="programlisting"><span class="keyword">using</span> <span class="identifier">python</span> <span class="special">:</span> <span class="number">2.5</span> <span class="special">:</span> <span class="identifier">C</span><span class="special">:\\</span><span class="identifier">src</span><span class="special">\\</span><span class="identifier">Python</span><span class="special">-</span><span class="number">2.5</span><span class="special">\\</span><span class="identifier">PCBuild</span><span class="special">\\</span><span class="identifier">python</span> <span class="special">;</span>
<span class="keyword">using</span> <span class="identifier">python</span> <span class="special">:</span> <span class="number">2.5</span> <span class="special">:</span> <span class="identifier">C</span><span class="special">:\\</span><span class="identifier">src</span><span class="special">\\</span><span class="identifier">Python</span><span class="special">-</span><span class="number">2.5</span><span class="special">\\</span><span class="identifier">PCBuild</span><span class="special">\\</span><span class="identifier">python_d</span>
  <span class="special">:</span> <span class="special">#</span> <span class="identifier">includes</span>
  <span class="special">:</span> <span class="special">#</span> <span class="identifier">libs</span>
  <span class="special">:</span> <span class="special">&lt;</span><span class="identifier">python</span><span class="special">-</span><span class="identifier">debugging</span><span class="special">&gt;</span><span class="identifier">on</span> <span class="special">;</span>
</pre>
</li>
<li class="listitem">
<p class="simpara">
              You can set up your user-config.jam so a bjam built under Windows can
              build/test both Windows and Cygwin_ python extensions. Just pass <code class="computeroutput"><span class="special">&lt;</span><span class="identifier">target</span><span class="special">-</span><span class="identifier">os</span><span class="special">&gt;</span><span class="identifier">cygwin</span></code>
              in the <code class="computeroutput"><span class="identifier">condition</span></code> parameter
              for the cygwin python installation:
            </p>
<pre class="programlisting"><span class="preprocessor"># windows</span> <span class="identifier">installation</span>
<span class="keyword">using</span> <span class="identifier">python</span> <span class="special">;</span>

<span class="preprocessor"># cygwin</span> <span class="identifier">installation</span>
<span class="keyword">using</span> <span class="identifier">python</span> <span class="special">:</span> <span class="special">:</span> <span class="identifier">c</span><span class="special">:\\</span><span class="identifier">cygwin</span><span class="special">\\</span><span class="identifier">bin</span><span class="special">\\</span><span class="identifier">python2</span><span class="special">.</span><span class="number">5</span> <span class="special">:</span> <span class="special">:</span> <span class="special">:</span> <span class="special">&lt;</span><span class="identifier">target</span><span class="special">-</span><span class="identifier">os</span><span class="special">&gt;</span><span class="identifier">cygwin</span> <span class="special">;</span>
</pre>
<p class="simpara">
              when you put target-os=cygwin in your build request, it should build
              with the cygwin version of python: <a name="flavor"></a>_
            </p>
<pre class="programlisting"><span class="identifier">bjam</span> <span class="identifier">target</span><span class="special">-</span><span class="identifier">os</span><span class="special">=</span><span class="identifier">cygwin</span> <span class="identifier">toolset</span><span class="special">=</span><span class="identifier">gcc</span>
</pre>
<p class="simpara">
              This is supposed to work the other way, too (targeting windows python
              with a <a href="http://cygwin.com" target="_top">Cygwin</a> bjam) but it seems
              as though the support in Boost.Build's toolsets for building that way
              is broken at the time of this writing.
            </p>
</li>
<li class="listitem">
<p class="simpara">
              Note that because of <a href="http://zigzag.cs.msu.su/boost.build/wiki/AlternativeSelection" target="_top">the
              way Boost.Build currently selects target alternatives</a>, you
              might have be very explicit in your build requests. For example, given:
            </p>
<pre class="programlisting"><span class="keyword">using</span> <span class="identifier">python</span> <span class="special">:</span> <span class="number">2.5</span> <span class="special">;</span> <span class="special">#</span> <span class="identifier">a</span> <span class="identifier">regular</span> <span class="identifier">windows</span> <span class="identifier">build</span>
<span class="keyword">using</span> <span class="identifier">python</span> <span class="special">:</span> <span class="number">2.4</span> <span class="special">:</span> <span class="special">:</span> <span class="special">:</span> <span class="special">:</span> <span class="special">&lt;</span><span class="identifier">target</span><span class="special">-</span><span class="identifier">os</span><span class="special">&gt;</span><span class="identifier">cygwin</span> <span class="special">;</span>
</pre>
<p class="simpara">
              building with
            </p>
<pre class="programlisting"><span class="identifier">bjam</span> <span class="identifier">target</span><span class="special">-</span><span class="identifier">os</span><span class="special">=</span><span class="identifier">cygwin</span>
</pre>
<p class="simpara">
              will yield an error. Instead, you'll need to write
            </p>
<pre class="programlisting"><span class="identifier">bjam</span> <span class="identifier">target</span><span class="special">-</span><span class="identifier">os</span><span class="special">=</span><span class="identifier">cygwin</span><span class="special">/</span><span class="identifier">python</span><span class="special">=</span><span class="number">2.4</span>
</pre>
</li>
</ul></div>
</div>
<div class="footnotes">
<br><hr style="width:100; text-align:left;margin-left: 0">
<div id="ftn.building.configuring_boost_build.f0" class="footnote"><p><a href="#building.configuring_boost_build.f0" class="para"><sup class="para">[2] </sup></a>
            <code class="computeroutput"><span class="identifier">configure</span></code> overwrites
            the existing <code class="computeroutput"><span class="identifier">user</span><span class="special">-</span><span class="identifier">config</span><span class="special">.</span><span class="identifier">jam</span></code> in your home directory (if any)
            after making a backup of the old version.
          </p></div>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
      Abrahams, Stefan Seefeld<br>Copyright © 2002-2015 David Abrahams, Stefan Seefeld<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="installing_boost_python_on_your_.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../building.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="choosing_a_boost_python_library_.html"><img src="../images/next.png" alt="Next"></a>
</div>
</body>
</html>
